<!DOCTYPE html>

<html>
<head>
  <title>parser_state.js</title>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
  <link rel="stylesheet" media="all" href="..\..\..\docco.css" />
</head>
<body>
  <div id="container">
    <div id="background"></div>
    
    <ul class="sections">
        
          <li id="title">
              <div class="annotation">
                  <h1>parser_state.js</h1>
              </div>
          </li>
        
        
        
        <li id="section-1">
            <div class="annotation">
              
              <div class="pilwrap ">
                <a class="pilcrow" href="#section-1">&#182;</a>
              </div>
              <p>State tracking for an in-progress parse and render.</p>

            </div>
            
            <div class="content"><div class='highlight'><pre><span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">ParserState</span> </span>{</pre></div></div>
            
        </li>
        
        
        <li id="section-2">
            <div class="annotation">
              
              <div class="pilwrap ">
                <a class="pilcrow" href="#section-2">&#182;</a>
              </div>
              <ul>
<li><strong>progress</strong> - DOM node to update to indicate completion progress.</li>
</ul>

            </div>
            
            <div class="content"><div class='highlight'><pre>  <span class="hljs-keyword">constructor</span>(progress) {</pre></div></div>
            
        </li>
        
        
        <li id="section-3">
            <div class="annotation">
              
              <div class="pilwrap ">
                <a class="pilcrow" href="#section-3">&#182;</a>
              </div>
              <p>Tracks the number of capture groups in the expression.</p>

            </div>
            
            <div class="content"><div class='highlight'><pre>    <span class="hljs-keyword">this</span>.groupCounter = <span class="hljs-number">1</span>;</pre></div></div>
            
        </li>
        
        
        <li id="section-4">
            <div class="annotation">
              
              <div class="pilwrap ">
                <a class="pilcrow" href="#section-4">&#182;</a>
              </div>
              <p>Cancels the in-progress render when set to true.</p>

            </div>
            
            <div class="content"><div class='highlight'><pre>    <span class="hljs-keyword">this</span>.cancelRender = <span class="hljs-literal">false</span>;</pre></div></div>
            
        </li>
        
        
        <li id="section-5">
            <div class="annotation">
              
              <div class="pilwrap ">
                <a class="pilcrow" href="#section-5">&#182;</a>
              </div>
              <p>Warnings that have been generated while rendering.</p>

            </div>
            
            <div class="content"><div class='highlight'><pre>    <span class="hljs-keyword">this</span>.warnings = [];</pre></div></div>
            
        </li>
        
        
        <li id="section-6">
            <div class="annotation">
              
              <div class="pilwrap ">
                <a class="pilcrow" href="#section-6">&#182;</a>
              </div>
              <p>Used to display the progress indicator</p>

            </div>
            
            <div class="content"><div class='highlight'><pre>    <span class="hljs-keyword">this</span>._renderCounter = <span class="hljs-number">0</span>;
    <span class="hljs-keyword">this</span>._maxCounter = <span class="hljs-number">0</span>;
    <span class="hljs-keyword">this</span>._progress = progress;
  }</pre></div></div>
            
        </li>
        
        
        <li id="section-7">
            <div class="annotation">
              
              <div class="pilwrap ">
                <a class="pilcrow" href="#section-7">&#182;</a>
              </div>
              <p>Counts the number of in-progress rendering steps. As the counter goes up,
a maximum value is also tracked. The maximum value and current render
counter are used to calculate the completion process.</p>

            </div>
            
            <div class="content"><div class='highlight'><pre>  get renderCounter() {
    <span class="hljs-keyword">return</span> <span class="hljs-keyword">this</span>._renderCounter;
  }

  set renderCounter(value) {
    <span class="hljs-keyword">if</span> (value &gt; <span class="hljs-keyword">this</span>.renderCounter) {
      <span class="hljs-keyword">this</span>._maxCounter = value;
    }

    <span class="hljs-keyword">this</span>._renderCounter = value;

    <span class="hljs-keyword">if</span> (<span class="hljs-keyword">this</span>._maxCounter &amp;&amp; !<span class="hljs-keyword">this</span>.cancelRender) {
      <span class="hljs-keyword">this</span>._progress.style.width = ((<span class="hljs-number">1</span> - <span class="hljs-keyword">this</span>.renderCounter / <span class="hljs-keyword">this</span>._maxCounter) * <span class="hljs-number">100</span>).toFixed(<span class="hljs-number">2</span>) + <span class="hljs-string">'%'</span>;
    }
  }
}</pre></div></div>
            
        </li>
        
    </ul>
  </div>
</body>
</html>
